/*
 * Copyright (C), 2002-2016, 苏宁易购电子商务有限公司
 * FileName: TypePercentVo.java
 * Author:   15050536
 * Date:     2016年12月6日 下午8:12:39
 * Description: //模块目的、功能描述      
 * History: //修改记录
 * <author>      <time>      <version>    <desc>
 * 修改人姓名             修改时间            版本号                  描述
 */
package com.suning.sawp.intf.tm.vo;

import java.io.Serializable;

/**
 * 类目及对应的百分比数据vo
 *
 * @author 15050536 石键平
 */
public class TypePercentVo implements Serializable,Comparable<TypePercentVo> {

	/**
	 */
	private static final long serialVersionUID = -1765642149406275839L;

	/**
	 * 类目编码
	 */
	private String type;
	
	/**
	 * 类目名称
	 */
	private String typeName;
	
	/**
	 * 百分比
	 */
	private String percent;

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public String getPercent() {
		return percent;
	}

	public void setPercent(String percent) {
		this.percent = percent;
	}

	@Override
	public int compareTo(TypePercentVo o2) {
		if(o2 == null){
			return -1;
		}
		float f1 = changePercentToPoint(this.getPercent());
		float f2 = changePercentToPoint(o2.getPercent());
		if (f1 > f2) {
			return -1;
		}
		if (f1 < f2) {
			return 1;
		}
		
		return 0;
	}
	
	private float changePercentToPoint(String percent) {
		if(percent == null){
			return 0f;
		}
        return new Float(percent.substring(0, percent.indexOf("%"))) / 100;
    }
	
    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }
}
